package cn.javase.concurrent._设计模式._同步模式之保护性暂停;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class Test {
    public static void main(String[] args) {
        GuardedObjectV2 guardedObject = new GuardedObjectV2();
        new Thread(() -> {
            try {
                Thread.sleep(3000);
                Object response = "232323223";
                log.debug("complete...");
                guardedObject.complete(response);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }).start();
        log.debug("waiting...");
        // 主线程阻塞等待
        Object response = guardedObject.get(4000);
        log.debug("get response: {}", response);
    }
}
